<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新增大类别</title>
<link rel="stylesheet" href="../static/css/reset.css">
<link rel="stylesheet" href="../static/css/adddlb.css">
</head>
<body>
<div class="user-content">
  <p class="user-admin"><span>当前页面 : </span><a href="dlb.html">大类别管理/</a><a class="active" href="adddlb.html">新增大类别</a></p>
  <form action="categoryAdd" method="post">
    <div class="user-add-infolist">
      <p class="user-add-title">新增大类别</p>
      <ul class="add-list">
        <li class="list-item">
          <label>类别名称</label>
          <input type="text" name="crop_category" class="cate" id="cate" />
          <span id="cateid"></span> </li>
        <li class="list-item">
          <label>类别图样</label>
          <!-- <input type="text" name="imgs" class="cate" id="cate" /> -->
          <div style="width:100px; height:100px; margin-left:80px; border:1px solid #000;"></div>
          <input type="file" value="选择图片" style="margin-left:80px;"/>
          <span id="cateid"></span> </li>
        <li class="list-item">
          <label>状态</label>
          <input type="radio" name="state" value="1" checked="checked" />
          启用
          <input type="radio" name="state" value="0" />
          禁用 </li>
      </ul>
      <div class="add-option"> <a class="user-save" onclick="bacun()">保存</a><a class="add-back" onclick="history.go(-1)">返回</a> </div>
    </div>
  </form>
</div>
</body>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">	
	  function bacun(){
	   var catename=$(".cate").val();
	   var url="jiaoyancate";
	   var parmas={"catename":catename};
	   $.post(url,parmas,function(date){
	   var catename1=JSON.parse(date);
	       if(catename1==false){
	           document.forms[0].submit();
	       }else{
	          alert("类别已经存在");
	          return false;
	       }
	   })
	   
	  }
	  
	</script>

</html>